add_library(ETHERNET_FILES STATIC)

target_sources(ETHERNET_FILES PUBLIC
    ${WIZNET_DIR}/Ethernet/socket.c
    ${WIZNET_DIR}/Ethernet/wizchip_conf.c
)

target_include_directories(ETHERNET_FILES INTERFACE
    ${WIZNET_DIR}/Ethernet
    ${WIZNET_DIR}/Ethernet/W5100S
)

target_link_libraries(ETHERNET_FILES PUBLIC
    W5100S_FILES
)

add_library(W5100S_FILES STATIC)

target_sources(W5100S_FILES PUBLIC
        ${WIZNET_DIR}/Ethernet/W5100S/w5100s.c
)

target_include_directories(W5100S_FILES INTERFACE
        ${WIZNET_DIR}/Ethernet
        ${WIZNET_DIR}/Ethernet/W5100S
)

target_link_libraries(W5100S_FILES PRIVATE
        ETHERNET_FILES
)

add_library(DHCP_FILES STATIC)
target_sources(DHCP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/DHCP/dhcp.c
)
target_include_directories(DHCP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/DHCP
)
target_link_libraries(DHCP_FILES PRIVATE
        ETHERNET_FILES
)

add_library(DNS_FILES STATIC)
target_sources(DNS_FILES PUBLIC
        ${WIZNET_DIR}/Internet/DNS/dns.c
)
target_include_directories(DNS_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/DNS
)
target_link_libraries(DNS_FILES PRIVATE
        ETHERNET_FILES
)


add_library(APP_FILES STATIC)
target_sources(APP_FILES PUBLIC
        ${WIZNET_DIR}/Application/loopback/loopback.c
)
target_include_directories(APP_FILES INTERFACE
        ${WIZNET_DIR}/Application
        ${WIZNET_DIR}/Application/loopback
)
target_link_libraries(APP_FILES PRIVATE
        ETHERNET_FILES
)


add_library(MULTI_FILES STATIC)
target_sources(MULTI_FILES PUBLIC
        ${WIZNET_DIR}/Application/multicast/multicast.c
)
target_include_directories(MULTI_FILES INTERFACE
        ${WIZNET_DIR}/Application
        ${WIZNET_DIR}/Application/multicast
)
target_link_libraries(MULTI_FILES PRIVATE
        ETHERNET_FILES
)


add_library(PING_FILES STATIC)
target_sources(PING_FILES PUBLIC
        ${WIZNET_DIR}/Application/PING/ping.c
)
target_include_directories(PING_FILES INTERFACE
        ${WIZNET_DIR}/Application
        ${WIZNET_DIR}/Application/PING
)
target_link_libraries(PING_FILES PRIVATE
        ETHERNET_FILES
        pico_stdlib
)



add_library(SNTP_FILES STATIC)
target_sources(SNTP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/SNTP/sntp.c
)
target_include_directories(SNTP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/sntp
)
target_link_libraries(SNTP_FILES PRIVATE
        ETHERNET_FILES
)



add_library(MQTT_FILES STATIC)
target_sources(MQTT_FILES PUBLIC
        ${WIZNET_DIR}/Internet/MQTT/mqtt_interface.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTConnect.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTConnectClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTConnectServer.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTDeserializePublish.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTFormat.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTPacket.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTPublish.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSerializePublish.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSubscribe.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSubscribeClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTSubscribeServer.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTUnsubscribe.h
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeClient.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/MQTTUnsubscribeServer.c
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src/StackTrace.h
)
target_include_directories(MQTT_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/MQTT
        ${WIZNET_DIR}/Internet/MQTT/MQTTPacket/src
)
target_link_libraries(MQTT_FILES PRIVATE
        ETHERNET_FILES
)
